<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <script type="text/javascript" src="js/jquery-1.4.1.js"></script>

    <script>
        $(function(){
            $(":button").click(function(){
                var username=$(":text").val();
                $.ajax({
                    //false表示同步
                    async:false,
                    url:"login",
                    type:"POST",
                    data:{
                        username:username,
                    },
                    success:function(data){
                        //把字符串转化成json对象
                        var data = eval("("+data+")");
                        if(data.status==0){
                            //error
                            alert(data.errorInfo);
                        }else{
                            //跳到welcome.jsp
                            window.location.href="welcome.jsp?username="+username;
                        }
                    },
                });
            });
        });
    </script>
</head>
<body>
    用户名：<input type="text" ><br>

    <input type="button" value="Login">

</body>
</html>